package com.cet.designpatterns.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-12 21:48
 **/
public class College extends OrganizationComponent {


    private List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public College(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }


    // 输出College中包含的系
    @Override
    public void print() {
        System.out.println("-------------" + getName() + "----------------");
        organizationComponents.forEach(OrganizationComponent::print);
    }
}
